//
//  MWNetworkManager.h
//  WuLianWang-iOS
//
//  Created by liuyiming on 2019/9/10.
//  Copyright © 2019 www.oakev.cn. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface MWNetworkManager : NSObject

+ (instancetype)manager;

/**
 *  发送get请求
 *
 *  @param url                      请求路径
 *  @param parameters               请求参数
 *  @param header                   请求头Header
 *  @param downloadProgressBlock    网络请求进度
 *  @param success                  请求成功后的回调,参数为id类型
 *  @param failure                  请求失败后的回调
 */
- (NSURLSessionDataTask *)GET:(NSString *)url
                   parameters:(id __nullable)parameters
          httpHeaderKeyValues:(NSDictionary *)header
                     progress:(void (^)(NSProgress *downloadProgress))downloadProgressBlock
                      success:(void (^)(id responseObject))success
                      failure:(void (^)(NSError *error))failure;

- (NSURLSessionDataTask *)GET:(NSString *)url
                   parameters:(id __nullable)parameters
                     progress:(void (^)(NSProgress *downloadProgress))downloadProgressBlock
                      success:(void (^)(id responseObject))success
                      failure:(void (^)(NSError *error))failure;

/**
 *  发送post请求
 *
 *  @param url          请求路径
 *  @param parameters   请求参数
 *  @param header       请求头Header
 *  @param success      请求成功后的回调,参数为id类型
 *  @param failure      请求失败后的回调
 */
- (NSURLSessionDataTask *)POST:(NSString *)url
                    parameters:(id)parameters
           httpHeaderKeyValues:(NSDictionary *)header
                      progress:(void (^)(NSProgress *downloadProgress))downloadProgressBlock
                       success:(void (^)(id responseObject))success
                       failure:(void (^)(NSError *error))failure;

- (NSURLSessionDataTask *)POST:(NSString *)url
                    parameters:(id)parameters
                      progress:(void (^)(NSProgress *downloadProgress))downloadProgressBlock
                       success:(void (^)(id responseObject))success
                       failure:(void (^)(NSError *error))failure;


- (void)uploadFile:(NSString *)url parameters:(id)parameters;

/**
 *  上传文件
 *
 *  @param url              请求路径
 *  @param parameters       请求参数
 *  @param success          请求成功后的回调,参数为id类型
 *  @param failure          请求失败后的回调
 */
- (NSURLSessionDataTask *)upload:(NSString *)url
                      parameters:(id)parameters
                         UIImage:image
                         success:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure;


/**
 *  下载
 *
 *  @param url                      请求路径
 *  @param parameters               请求参数
 *  @param header                   请求头Header
 *  @param downloadProgressBlock    下载进度
 *  @param destination              请求成功后的回调,参数为id类型
 *  @param completionHandler        请求失败后的回调
 */
- (NSURLSessionDownloadTask *)download:(NSString *)url
                            parameters:(id)parameters
                   httpHeaderKeyValues:(NSDictionary *)header
                              progress:(void (^)(NSProgress *downloadProgress))downloadProgressBlock
                           destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
                     completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler;

- (NSURLSessionDownloadTask *)download:(NSString *)url
                            parameters:(id)parameters
                              progress:(void (^)(NSProgress *downloadProgress))downloadProgressBlock
                           destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
                     completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler;



@end

NS_ASSUME_NONNULL_END
